<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>ar.com.hjg.pngj (PNGJ 2.1.1-SNAPSHOT API)</title>
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="ar.com.hjg.pngj (PNGJ 2.1.1-SNAPSHOT API)";
    }
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!--   -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li class="navBarCell1Rev">Package</li>
<li>Class</li>
<li><a href="package-use.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Package</li>
<li><a href="../../../../ar/com/hjg/pngj/chunks/package-summary.html">Next Package</a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?ar/com/hjg/pngj/package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<a name="skip-navbar_top">
<!--   -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 title="Package" class="title">Package&nbsp;ar.com.hjg.pngj</h1>
<div class="docSummary">
<div class="block">
PNGJ main package</div>
</div>
<p>See:&nbsp;<a href="#package_description">Description</a></p>
</div>
<div class="contentContainer">
<ul class="blockList">
<li class="blockList">
<table class="packageSummary" border="0" cellpadding="3" cellspacing="0" summary="Interface Summary table, listing interfaces, and an explanation">
<caption><span>Interface Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Interface</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/IBytesConsumer.html" title="interface in ar.com.hjg.pngj">IBytesConsumer</a></td>
<td class="colLast">
<div class="block">Bytes consumer.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/IChunkFactory.html" title="interface in ar.com.hjg.pngj">IChunkFactory</a></td>
<td class="colLast">
<div class="block">Factory to create a <a href="../../../../ar/com/hjg/pngj/chunks/PngChunk.html" title="class in ar.com.hjg.pngj.chunks"><code>PngChunk</code></a> from a <a href="../../../../ar/com/hjg/pngj/chunks/ChunkRaw.html" title="class in ar.com.hjg.pngj.chunks"><code>ChunkRaw</code></a>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/IImageLine.html" title="interface in ar.com.hjg.pngj">IImageLine</a></td>
<td class="colLast">
<div class="block">General format-translated image line.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/IImageLineArray.html" title="interface in ar.com.hjg.pngj">IImageLineArray</a></td>
<td class="colLast">
<div class="block">This interface is just for the sake of unifying some methods of <a href="../../../../ar/com/hjg/pngj/ImageLineHelper.html" title="class in ar.com.hjg.pngj"><code>ImageLineHelper</code></a> that can use both
 <a href="../../../../ar/com/hjg/pngj/ImageLineInt.html" title="class in ar.com.hjg.pngj"><code>ImageLineInt</code></a> or <a href="../../../../ar/com/hjg/pngj/ImageLineByte.html" title="class in ar.com.hjg.pngj"><code>ImageLineByte</code></a>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/IImageLineFactory.html" title="interface in ar.com.hjg.pngj">IImageLineFactory</a>&lt;T extends <a href="../../../../ar/com/hjg/pngj/IImageLine.html" title="interface in ar.com.hjg.pngj">IImageLine</a>&gt;</td>
<td class="colLast">
<div class="block">Image Line factory.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/IImageLineSet.html" title="interface in ar.com.hjg.pngj">IImageLineSet</a>&lt;T extends <a href="../../../../ar/com/hjg/pngj/IImageLine.html" title="interface in ar.com.hjg.pngj">IImageLine</a>&gt;</td>
<td class="colLast">
<div class="block">Set of <a href="../../../../ar/com/hjg/pngj/IImageLine.html" title="interface in ar.com.hjg.pngj"><code>IImageLine</code></a> elements.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/IImageLineSetFactory.html" title="interface in ar.com.hjg.pngj">IImageLineSetFactory</a>&lt;T extends <a href="../../../../ar/com/hjg/pngj/IImageLine.html" title="interface in ar.com.hjg.pngj">IImageLine</a>&gt;</td>
<td class="colLast">
<div class="block">Factory of <a href="../../../../ar/com/hjg/pngj/IImageLineSet.html" title="interface in ar.com.hjg.pngj"><code>IImageLineSet</code></a>, used by <a href="../../../../ar/com/hjg/pngj/PngReader.html" title="class in ar.com.hjg.pngj"><code>PngReader</code></a>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/IPngWriterFactory.html" title="interface in ar.com.hjg.pngj">IPngWriterFactory</a></td>
<td class="colLast">&nbsp;</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="packageSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation">
<caption><span>Class Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Class</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/BufferedStreamFeeder.html" title="class in ar.com.hjg.pngj">BufferedStreamFeeder</a></td>
<td class="colLast">
<div class="block">Reads bytes from an input stream, and feeds a IBytesConsumer.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/ChunkReader.html" title="class in ar.com.hjg.pngj">ChunkReader</a></td>
<td class="colLast">
<div class="block">Parses a PNG chunk, consuming bytes in one mode: <a href="../../../../ar/com/hjg/pngj/ChunkReader.ChunkReaderMode.html#BUFFER"><code>ChunkReader.ChunkReaderMode.BUFFER</code></a>, <a href="../../../../ar/com/hjg/pngj/ChunkReader.ChunkReaderMode.html#PROCESS"><code>ChunkReader.ChunkReaderMode.PROCESS</code></a>,
 <a href="../../../../ar/com/hjg/pngj/ChunkReader.ChunkReaderMode.html#SKIP"><code>ChunkReader.ChunkReaderMode.SKIP</code></a>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/ChunkSeqBuffering.html" title="class in ar.com.hjg.pngj">ChunkSeqBuffering</a></td>
<td class="colLast">
<div class="block">This loads the png as a plain sequence of chunks, buffering all
 
 Useful to do things like insert or delete a ancilllary chunk.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/ChunkSeqReader.html" title="class in ar.com.hjg.pngj">ChunkSeqReader</a></td>
<td class="colLast">
<div class="block">Consumes a stream of bytes that consist of a series of PNG-like chunks.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/ChunkSeqReaderPng.html" title="class in ar.com.hjg.pngj">ChunkSeqReaderPng</a></td>
<td class="colLast">
<div class="block">Adds to ChunkSeqReader the storing of PngChunk, with a PngFactory, and imageInfo + deinterlacer.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/ChunkSeqSkipping.html" title="class in ar.com.hjg.pngj">ChunkSeqSkipping</a></td>
<td class="colLast">
<div class="block">This simple reader skips all chunks contents and stores the chunkRaw in a list.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/DeflatedChunkReader.html" title="class in ar.com.hjg.pngj">DeflatedChunkReader</a></td>
<td class="colLast">
<div class="block">Specialization of ChunkReader, for IDAT-like chunks.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/DeflatedChunksSet.html" title="class in ar.com.hjg.pngj">DeflatedChunksSet</a></td>
<td class="colLast">
<div class="block">A set of IDAT-like chunks which, concatenated, form a zlib stream.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/Deinterlacer.html" title="class in ar.com.hjg.pngj">Deinterlacer</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/IDatChunkWriter.html" title="class in ar.com.hjg.pngj">IDatChunkWriter</a></td>
<td class="colLast">
<div class="block">Outputs a sequence of IDAT-like chunk, that is filled progressively until the max chunk length is reached (or until
 flush())</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/IdatSet.html" title="class in ar.com.hjg.pngj">IdatSet</a></td>
<td class="colLast">
<div class="block">This object process the concatenation of IDAT chunks.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/ImageInfo.html" title="class in ar.com.hjg.pngj">ImageInfo</a></td>
<td class="colLast">
<div class="block">Simple immutable wrapper for basic image info.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/ImageLineByte.html" title="class in ar.com.hjg.pngj">ImageLineByte</a></td>
<td class="colLast">
<div class="block">Lightweight wrapper for an image scanline, used for read and write.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/ImageLineHelper.html" title="class in ar.com.hjg.pngj">ImageLineHelper</a></td>
<td class="colLast">
<div class="block">Bunch of utility static methods to proces an image line at the pixel level.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/ImageLineInt.html" title="class in ar.com.hjg.pngj">ImageLineInt</a></td>
<td class="colLast">
<div class="block">Represents an image line, integer format (one integer by sample).</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/ImageLineSetDefault.html" title="class in ar.com.hjg.pngj">ImageLineSetDefault</a>&lt;T extends <a href="../../../../ar/com/hjg/pngj/IImageLine.html" title="interface in ar.com.hjg.pngj">IImageLine</a>&gt;</td>
<td class="colLast">
<div class="block">Default implementation of <a href="../../../../ar/com/hjg/pngj/IImageLineSet.html" title="interface in ar.com.hjg.pngj"><code>IImageLineSet</code></a>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngHelperInternal.html" title="class in ar.com.hjg.pngj">PngHelperInternal</a></td>
<td class="colLast">
<div class="block">Some utility static methods for internal use.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngReader.html" title="class in ar.com.hjg.pngj">PngReader</a></td>
<td class="colLast">
<div class="block">Reads a PNG image (pixels and/or metadata) from a file or stream.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngReaderApng.html" title="class in ar.com.hjg.pngj">PngReaderApng</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngReaderByte.html" title="class in ar.com.hjg.pngj">PngReaderByte</a></td>
<td class="colLast">
<div class="block">Trivial extension of <a href="../../../../ar/com/hjg/pngj/PngReader.html" title="class in ar.com.hjg.pngj"><code>PngReader</code></a> that uses <a href="../../../../ar/com/hjg/pngj/ImageLineByte.html" title="class in ar.com.hjg.pngj"><code>ImageLineByte</code></a></div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngReaderFilter.html" title="class in ar.com.hjg.pngj">PngReaderFilter</a></td>
<td class="colLast">
<div class="block">This class allows to use a simple PNG reader as an input filter, wrapping a ChunkSeqReaderPng in callback mode.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngReaderInt.html" title="class in ar.com.hjg.pngj">PngReaderInt</a></td>
<td class="colLast">
<div class="block">Trivial extension of <a href="../../../../ar/com/hjg/pngj/PngReader.html" title="class in ar.com.hjg.pngj"><code>PngReader</code></a> that uses <a href="../../../../ar/com/hjg/pngj/ImageLineInt.html" title="class in ar.com.hjg.pngj"><code>ImageLineInt</code></a>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngWriter.html" title="class in ar.com.hjg.pngj">PngWriter</a></td>
<td class="colLast">
<div class="block">Writes a PNG image, line by line.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngWriterHc.html" title="class in ar.com.hjg.pngj">PngWriterHc</a></td>
<td class="colLast">
<div class="block">Pngwriter with High compression EXPERIMENTAL</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="packageSummary" border="0" cellpadding="3" cellspacing="0" summary="Enum Summary table, listing enums, and an explanation">
<caption><span>Enum Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Enum</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/ChunkReader.ChunkReaderMode.html" title="enum in ar.com.hjg.pngj">ChunkReader.ChunkReaderMode</a></td>
<td class="colLast">
<div class="block">Modes of ChunkReader chunk processing.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/FilterType.html" title="enum in ar.com.hjg.pngj">FilterType</a></td>
<td class="colLast">
<div class="block">Internal PNG predictor filter type
 
 Negative values are pseudo types, actually global strategies for writing, that (can) result on different real filters
 for different rows</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="packageSummary" border="0" cellpadding="3" cellspacing="0" summary="Exception Summary table, listing exceptions, and an explanation">
<caption><span>Exception Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Exception</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngjBadCrcException.html" title="class in ar.com.hjg.pngj">PngjBadCrcException</a></td>
<td class="colLast">
<div class="block">Exception thrown by bad CRC check</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngjException.html" title="class in ar.com.hjg.pngj">PngjException</a></td>
<td class="colLast">
<div class="block">Generic exception for this library.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngjExceptionInternal.html" title="class in ar.com.hjg.pngj">PngjExceptionInternal</a></td>
<td class="colLast">
<div class="block">Exception for anomalous internal problems (sort of asserts) that point to some issue with the library</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngjInputException.html" title="class in ar.com.hjg.pngj">PngjInputException</a></td>
<td class="colLast">
<div class="block">Exception thrown when reading a PNG.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngjOutputException.html" title="class in ar.com.hjg.pngj">PngjOutputException</a></td>
<td class="colLast">
<div class="block">Exception thrown by writing process</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../ar/com/hjg/pngj/PngjUnsupportedException.html" title="class in ar.com.hjg.pngj">PngjUnsupportedException</a></td>
<td class="colLast">
<div class="block">Exception thrown because of some valid feature of PNG standard that this library does not support.</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
<a name="package_description">
<!--   -->
</a>
<h2 title="Package ar.com.hjg.pngj Description">Package ar.com.hjg.pngj Description</h2>
<div class="block"><p>
PNGJ main package
</p>
<p>
Users of this library should rarely need more than the public members of this package.<br>
Newcomers: start with <a href="PngReader.html">PngReader</a> and <a href="PngWriter.html">PngWriter</a>.
</p>
<p>
Example of use: this code reads a true colour PNG image (RGB8 or RGBA8) 
and reduces the red channel by half, increasing the green by 20.
It copies all the "safe" metadata from the original image, and adds a textual metadata.
  
<pre class="code">
  public static void convert(String origFilename, String destFilename) {
    // you can also use PngReader (esentially the same) or PngReaderByte 
    PngReaderInt pngr = new PngReaderInt(new File(origFilename));  
    System.out.println(pngr.toString());
    int channels = pngr.imgInfo.channels;
    if (channels &lt; 3 || pngr.imgInfo.bitDepth != 8)
       throw new RuntimeException("For simplicity this supports only RGB8/RGBA8 images");
    // writer with same image properties as original
    PngWriter pngw = new PngWriter(new File(destFilename), pngr.imgInfo, true);
    // instruct the writer to grab all ancillary chunks from the original
    pngw.copyChunksFrom(pngr.getChunksList(), ChunkCopyBehaviour.COPY_ALL_SAFE);
    // add a textual chunk to writer
    pngw.getMetadata().setText(PngChunkTextVar.KEY_Description, "Decreased red and increased green");
    // also: while(pngr.hasMoreRows())
    for (int row = 0; row &lt; pngr.imgInfo.rows; row++) {  
       ImageLineInt l1 = pngr.readRowInt(); // each element is a sample
       int[] scanline = l1.getScanline(); // to save typing
       for (int j = 0; j < pngr.imgInfo.cols; j++) {
          scanline[j * channels] /= 2;
          scanline[j * channels + 1] = ImageLineHelper.clampTo_0_255(scanline[j * channels + 1] + 20);
       }
       pngw.writeRow(l1);
    }
    pngr.end(); // it's recommended to end the reader first, in case there are trailing chunks to read
    pngw.end();
 }

</pre>

For more examples, see the tests and samples.

</p></div>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!--   -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li class="navBarCell1Rev">Package</li>
<li>Class</li>
<li><a href="package-use.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Package</li>
<li><a href="../../../../ar/com/hjg/pngj/chunks/package-summary.html">Next Package</a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?ar/com/hjg/pngj/package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<a name="skip-navbar_bottom">
<!--   -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2014. All rights reserved.</small></p>
</body>
</html>
